import 'package:base_flutter/base_flutter.dart';
import 'package:ls_work/doctor_advice/doctor_advice_api.dart';
import 'package:ls_work/doctor_advice/response/advice_notify_type_list.dart';
import 'package:ls_work/doctor_advice/response/medical_equipment_list.dart';
class DoctorAdviceModel extends BaseMvvmModel{
  @override
  void onCleared() {
  }


  ///设备列表
  Future<List<MedicalEquipmentList>> medicalEquipment({int type = 1,int rows =1000}) async {
    var map = {
      "type":type,
      "rows":rows
    };
    var data = await HttpGo.instance.postData(DoctorAdviceApi.medicalEquipment,data: map,options: Options(contentType: Headers.jsonContentType));
    if("0"==data['code']){
      return ((data['data']['rows'] as List?)??[]).map((e)=>MedicalEquipmentList.fromJson(e)).toList();
    }else{
      throw data['msg'];
    }
  }

  ///通知类型列表
  Future<List<AdviceNotifyTypeList>> notifyTypeList({int codeAtt = 1}) async {
    var map = {
      "codeAtt":codeAtt
    };
    var data = await HttpGo.instance.postData(DoctorAdviceApi.notifyTypeList,data: map,options: Options(contentType: Headers.jsonContentType));
    if("0"==data['code']){
      return ((data['data']['rows'] as List?)??[]).map((e)=>AdviceNotifyTypeList.fromJson(e)).toList();
    }else{
      throw data['msg'];
    }
  }

  Future<Map> saveAdvice(Map map) async {
    var data = await HttpGo.instance.postData(DoctorAdviceApi.saveAdvice,data: map,options: Options(contentType: Headers.jsonContentType));
    if("0"==data['code']){
      return data;
    }else{
      throw data['msg'];
    }
  }
}